package com.jinbm.fileservice.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author:JinBoming
 * Date:2023/9/8
 * Time:16:55
 **/
@Configuration
@ConfigurationProperties(prefix = "spring.minio")
public class MinioConfig {

    @Value("${minio.access-key}")
    private String accessKey;

    @Value("${minio.secret-key}")
    private String secretKey;

    @Value("${minio.port}")
    private String port;

    @Value("${minio.url}")
    private String url;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(url+":"+port)
                .credentials(accessKey, secretKey)
                .build();
    }
}
